package com.invest.infra.excel.validator.impl;

import com.invest.infra.excel.validator.CellValidator;
import com.invest.utils.date.DateParseHelper;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service("dateValidator")
public class DateValidator implements CellValidator {

	@Override
	public String validate(Map<String,Object> extMap,String value) {
		if(StringUtils.isNotBlank(value)){
			try{
				 value = StringUtils.left(value, 10);
				 DateParseHelper.parse(value);
			}catch(Exception e){
				return "日期格式不正确";
			}
		}
		return null;
	}

}
